//
//  InternalCollectionViewCell.m
//  day-07
//
//  Created by hcios on 2017/7/9.
//  Copyright © 2017年 hcios. All rights reserved.
//

#import "InternalCollectionViewCell.h"
#import "UIImageView+WebCache.h"

#define FONT_NAME_LTH @"FZLanTingHeiS-R-GB"
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)

@implementation InternalCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupSubViews];
    }
    return self;
}

-(void)setModel:(InternalModel *)model{
    
    [_cityImage sd_setImageWithURL:[NSURL URLWithString:model.destinations_image_url] placeholderImage:[UIImage imageNamed:@"zhanWeiTu"]];
    _cityNameLabel.text = model.destinations_name_zh_cn;
    _spellLabel.text = model.destinations_name_en;
    _summaryLabel.text = [NSString stringWithFormat:@"旅行地：%@",model.destinations_poi_count];
}


-(void)setupSubViews{
    
    _cityImage = [[UIImageView alloc]init];
    [_cityImage setFrame:self.bounds];
    _cityImage.layer.cornerRadius = 4;
    _cityImage.layer.masksToBounds = YES;
    _cityImage.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:_cityImage];
    
    _cityNameLabel = [[UILabel alloc] init];
    [_cityNameLabel setFrame:CGRectMake(10, 15, self.frame.size.width, 30)];
    [_cityNameLabel setFont:[UIFont fontWithName:FONT_NAME_LTH size:18]];
    [_cityNameLabel setTextColor:[UIColor whiteColor]];
    _cityNameLabel.textAlignment = NSTextAlignmentLeft;
    self.cityNameLabel.shadowColor = [UIColor grayColor];
    self.cityNameLabel.shadowOffset = CGSizeMake(1, 1);
    [_cityImage addSubview:_cityNameLabel];
    
    _spellLabel = [[UILabel alloc] init];
    [_spellLabel setFrame:CGRectMake(10, CGRectGetMaxY(_cityNameLabel.frame), self.frame.size.width, 20)];
    [_spellLabel setFont:[UIFont fontWithName:FONT_NAME_LTH size:16]];
    [_spellLabel setTextColor:[UIColor whiteColor]];
    _spellLabel.textAlignment = NSTextAlignmentLeft;
    _spellLabel.numberOfLines = 0;
    self.spellLabel.shadowColor = [UIColor grayColor];
    self.spellLabel.shadowOffset = CGSizeMake(1, 1);
    [_cityImage addSubview:_spellLabel];
    
    _summaryLabel = [[UILabel alloc] init];
    [_summaryLabel setFrame:CGRectMake((self.frame.size.width/2)-50, self.frame.size.height - 60, 100, 20)];
    [_summaryLabel setFont:[UIFont fontWithName:FONT_NAME_LTH size:13]];
    [_summaryLabel setTextColor:[UIColor lightGrayColor]];
    _summaryLabel.textAlignment = NSTextAlignmentCenter;
    _summaryLabel.backgroundColor = RGB(39, 12, 10);
    _summaryLabel.layer.cornerRadius = 10;
    _summaryLabel.layer.masksToBounds = YES;
    [_cityImage addSubview:_summaryLabel];
    
    
    
}

@end
